package com.zili.transformation;

import com.zili.source.Event;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author : ranzlupup
 * @date : 2023/3/7 16:49
 */
public class TransformMapTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        DataStreamSource<Event> stream = env.fromElements(
                new Event("Mary", "./home", 1000L),
                new Event("Bob", "./cart", 2000L),
                new Event("zl", "./goods", 3000L)

        );
        // stream.map(new MapFunction<Event, String>() {
        //     @Override
        //     public String map(Event event) throws Exception {
        //         return event.user;
        //     }
        // });

        SingleOutputStreamOperator<String> mapStream = stream.map(data -> data.user);

        mapStream.print();
        env.execute();
    }
}
